﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Crystalbyte.Equinox;
using Crystalbyte.Equinox.Imap;
using Crystalbyte.Equinox.Security;
using Crystalbyte.Equinox.Security.Authentication;

namespace GmailFetcher.Models
{
    class EmailMessage
    {

        public Envelope Envelope { get; set; }
        public MessageInfo BodyStructure { get; set; }
        public int Uid { get; set; }
        public MessageFlags Flags { get; set; }
        public string Text { get; set; }

        public string Subject
        {
            get { return Envelope == null ? string.Empty : Envelope.Subject; }
        }

        public DateTime? Date
        {
            get { return Envelope != null ? Envelope.Date : null; }
        }

        public string From
        {
            get { return Envelope.From != null && Envelope.From.Count() > 0 ? Envelope.From.First().ToString() : string.Empty; }
        }

        public string To
        {
            get { return Envelope.To != null && Envelope.To.Count() > 0 ? Envelope.To.First().ToString() : string.Empty; }
        }


    }
}
